── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.0 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.0
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(here)
here() starts at /Users/apple/Desktop/ling343-files/homework-5-beckyjyn
install.packages("knitr")
The downloaded binary packages are in
/var/folders/y4/2c8ll6k92nd21739y4jnkk7w0000gn/T//Rtmp8TzD6f/downloaded_packages
install.packages("kableExtra")
The downloaded binary packages are in
/var/folders/y4/2c8ll6k92nd21739y4jnkk7w0000gn/T//Rtmp8TzD6f/downloaded_packages
library(knitr)library(kableExtra)
Attaching package: 'kableExtra'
The following object is masked from 'package:dplyr':
group_rows
library(tibble)install.packages("gt")
The downloaded binary packages are in
/var/folders/y4/2c8ll6k92nd21739y4jnkk7w0000gn/T//Rtmp8TzD6f/downloaded_packages
library(gt)install.packages("ggplot2")
The downloaded binary packages are in
/var/folders/y4/2c8ll6k92nd21739y4jnkk7w0000gn/T//Rtmp8TzD6f/downloaded_packages
install.packages("plotly")
The downloaded binary packages are in
/var/folders/y4/2c8ll6k92nd21739y4jnkk7w0000gn/T//Rtmp8TzD6f/downloaded_packages
library(ggplot2)library(plotly)
Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':
last_plot
The following object is masked from 'package:stats':
filter
The following object is masked from 'package:graphics':
layout
Importing Data
here::i_am("analysis/homework5-beckyjyn.qmd")
here() starts at /Users/apple/Desktop/ling343-files/homework-5-beckyjyn
`summarise()` has grouped output by 'Hash'. You can override using the
`.groups` argument.
expect
RT
expected
672.12
unexpected
716.56
set.seed(343)p_parts <- rt.s.filt |>filter(rgn.fix ==0) |>group_by(Hash, expect) |>summarize(RT =mean(RT, na.rm =TRUE)) |>ggplot(aes(x=expect, y=RT, color = expect)) +geom_jitter(stat ="identity", width = .1, alpha = .8) +geom_point(stat ="summary", fun = mean, shape =4, color ="blue", size =4) +labs(x ="Condition", y ="Reading Time (msec)") +theme_bw()
`summarise()` has grouped output by 'Hash'. You can override using the
`.groups` argument.
ggplotly(p_parts)
Describe the study
This study concentrates on investigating how English speakers predict following phonological forms based on grammatical and phonetic cues, using the choice between articles “a” and “an” as an instance. Whether “a” or “an” is required depends on the initial sound of the word that follows the article. Usually, words that begin a vowel sound would need “an” while the ones that begin with a consonant would rather need “a”.
# A tibble: 24 × 2
Variable Valid_cnts
<chr> <int>
1 Index 73632
2 Time 73632
3 Counter 73632
4 Hash 73632
5 Owner 73632
6 Controller 73632
7 Item 73632
8 Element 73632
9 Type 73632
10 Group 73632
# ℹ 14 more rows
variable_explained <-tribble(~Essential_Variable, ~Description,"Hash", "hash key of each participant","Owner", "whether the participant is experiment owner or not","Controller", "{Form|Maze|Question}","Item", "sentence item index","Type", "type of the given task","Group", "group of the given stimuli","Word", "original word in sentence","Alt", "word alternative to the original word","WordOn", "boolean value that determines the word is which of the above two types","CorrWord", "if the word is correct or incorrect","RT", "response time","Sent", "the complete sentence","TotalTime", "time taken for a correct response","Question", "comprehension question", "Resp", "participant's response to the above question","Acc", "reponse is correctly accepted or not","RespRT", "reaction time of the response")print(variable_explained)
# A tibble: 17 × 2
Essential_Variable Description
<chr> <chr>
1 Hash hash key of each participant
2 Owner whether the participant is experiment owner or not
3 Controller {Form|Maze|Question}
4 Item sentence item index
5 Type type of the given task
6 Group group of the given stimuli
7 Word original word in sentence
8 Alt word alternative to the original word
9 WordOn boolean value that determines the word is which of the ab…
10 CorrWord if the word is correct or incorrect
11 RT response time
12 Sent the complete sentence
13 TotalTime time taken for a correct response
14 Question comprehension question
15 Resp participant's response to the above question
16 Acc reponse is correctly accepted or not
17 RespRT reaction time of the response
participant_info <-tribble(~Abbrev, ~Full,"age", "-","natlang", "Native language learned","state", "-","parentlang", "Language used by their parents","domlang", "Dominant language", "otherlang", "Other language learned","gender", "-","question- ", "...")print(participant_info)
# A tibble: 8 × 2
Abbrev Full
<chr> <chr>
1 "age" -
2 "natlang" Native language learned
3 "state" -
4 "parentlang" Language used by their parents
5 "domlang" Dominant language
6 "otherlang" Other language learned
7 "gender" -
8 "question- " ...
How many participants does the data have data in total?
Use inline R-code to “print” this number in the markdown text.
rgn.fix expect subj sd stderr CW-3 CW-2 CW-1
1 -3 expected 36 285.8839 47.64731 753.1880 NA NA
2 -3 unexpected 36 306.2786 51.04644 757.1725 NA NA
3 -2 expected 36 309.4916 51.58193 NA 733.0036 NA
4 -2 unexpected 36 411.7028 68.61713 NA 742.7986 NA
5 -1 expected 36 323.5000 53.91667 NA NA 760.2436
6 -1 unexpected 36 272.0673 45.34454 NA NA 751.1713
7 0 expected 36 224.8922 37.48203 NA NA NA
8 0 unexpected 36 339.1033 56.51721 NA NA NA
9 1 expected 36 255.3778 42.56296 NA NA NA
10 1 unexpected 36 542.2348 90.37247 NA NA NA
11 2 expected 36 327.1993 54.53322 NA NA NA
12 2 unexpected 36 1168.4236 194.73727 NA NA NA
13 3 expected 36 324.7641 54.12735 NA NA NA
14 3 unexpected 36 389.0720 64.84534 NA NA NA
15 4 expected 36 296.2991 49.38319 NA NA NA
16 4 unexpected 36 297.0947 49.51578 NA NA NA
art n CW+1 CW+2 CW+3
1 NA NA NA NA NA
2 NA NA NA NA NA
3 NA NA NA NA NA
4 NA NA NA NA NA
5 NA NA NA NA NA
6 NA NA NA NA NA
7 674.1306 NA NA NA NA
8 719.3884 NA NA NA NA
9 NA 704.219 NA NA NA
10 NA 1061.635 NA NA NA
11 NA NA 781.0073 NA NA
12 NA NA 859.8654 NA NA
13 NA NA NA 785.0631 NA
14 NA NA NA 793.6538 NA
15 NA NA NA NA 766.7514
16 NA NA NA NA 789.8782
rt.s.filt |>filter(rgn.fix ==0) |>group_by(Hash, expect) |>summarize(RT =mean(RT, na.rm =TRUE)) |>ggplot(aes(x=expect, y=RT, shape = expect, group = Hash, color = Hash)) +geom_line() +geom_point(stat ="identity", alpha = .8, size =2) +labs(x ="Condition", y ="Reading Time (msec)") +theme_minimal() +theme(legend.position ="none")
`summarise()` has grouped output by 'Hash'. You can override using the
`.groups` argument.
# package for linear mixed effectslibrary(lme4)
Loading required package: Matrix
Attaching package: 'Matrix'
The following objects are masked from 'package:tidyr':
expand, pack, unpack
Warning in check_dep_version(): ABI version mismatch:
lme4 was built with Matrix ABI version 1
Current Matrix ABI version is 0
Please re-install lme4 from source or restore original 'Matrix' package
# package for p-values from lme4 modelslibrary(lmerTest)
Attaching package: 'lmerTest'
The following object is masked from 'package:lme4':
lmer
The following object is masked from 'package:stats':
step
m_lm <-lm(RT ~ expect, data =filter(rt.s.filt, rgn.fix ==0))summary(m_lm)
Call:
lm(formula = RT ~ expect, data = filter(rt.s.filt, rgn.fix ==
0))
Residuals:
Min 1Q Median 3Q Max
-603.8 -159.8 -66.9 62.4 3964.2
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 672.017 7.675 87.557 < 2e-16 ***
expectunexpected 44.803 10.847 4.131 3.72e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 289.2 on 2842 degrees of freedom
Multiple R-squared: 0.005968, Adjusted R-squared: 0.005618
F-statistic: 17.06 on 1 and 2842 DF, p-value: 3.723e-05
install.packages("gtsummary")
The downloaded binary packages are in
/var/folders/y4/2c8ll6k92nd21739y4jnkk7w0000gn/T//Rtmp8TzD6f/downloaded_packages